home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Dev / misc / temgen.lha / Temgen / tg-0.11 / structs.h < prev    next >
C/C++ Source or Header  |  2002-12-18  |  4KB  |  187 lines

  1. #ifndef __structs_h_
  2. #define __structs_h_
  3.  
  4. #include "txttab.h"
  5. #include "lintab.h"
  6.  
  7. struct object
  8. {
  9.     struct object *h;
  10.     struct object_part *t;
  11. };
  12.  
  13. struct object_part
  14. {
  15.     char      type;
  16.     union op_value {
  17.         int      name;
  18.         struct   funpart {
  19.             struct object_part *h;
  20.             struct explist *l;
  21.         } f;
  22.         struct   tabpart {
  23.             struct object_part *h;
  24.             struct expression *e;
  25.         } t;
  26.         struct   exppart {
  27.             struct expression *e;
  28.         } e;
  29.     } val;
  30. };
  31.  
  32. struct expression
  33. {
  34.     char    type;
  35.     union   ex_value {
  36.         int            i;
  37.         float          f;
  38.         char          *s;
  39.         struct object *o;
  40.         struct   operation {
  41.             struct expression *a, *b;
  42.             char op;     /*  + - * / e = < > !("!=") l g n("!")
  43.                              i (x++)  d (x--)  I (++x)  D (--x) 
  44.                              1 (*=)   2 (/=)   3 (+=)   4 (-=)     .....  */
  45.         } oper;
  46.         struct array {
  47.             int           reg;
  48.             struct explist *l;
  49.         } a;
  50.         struct record {
  51.             int           reg;
  52.             struct fldlist *l;
  53.         } r;
  54.     } val;
  55. };
  56.  
  57. struct explist  {
  58.     struct explist *h;
  59.     struct expression *t;
  60. };
  61.  
  62. struct fldlist {
  63.     struct fldlist    *h;
  64.     int             name;
  65.     struct expression *e;
  66. };
  67.  
  68. /* command types */
  69. #define      CMD_IF             'i'  
  70. #define      CMD_FUNCTION       'F'
  71. #define      CMD_SWITCH         's'
  72. #define      CMD_FOR            'f'
  73. #define      CMD_RETURN         'r'
  74. #define      CMD_BREAK          'b'
  75. #define      CMD_GOTO           'g'
  76. #define      CMD_EXP            'e'
  77. #define      CMD_DATA           'd'
  78. #define      CMD_EMBED          '<'
  79. #define      CMD_EMIT           '>'
  80. #define      CMD_PUSH           'p'
  81. #define      CMD_POP            'P'
  82. #define      CMD_OUTPUT         'o'
  83. #define      CMD_LOCAL          'l'
  84. #define      CMD_USE            'u'
  85. #define      CMD_EXIT           'x'
  86.  
  87. struct param {
  88.     struct  param *h; 
  89.     int            t;
  90. };
  91.  
  92. struct paramlist {
  93.     struct  paramlist *h; 
  94.     char              *t;
  95. };
  96.  
  97. struct caselist
  98. {
  99.     struct caselist     *h;
  100.     struct expression   *e;
  101.     int               line;
  102. };
  103.  
  104. struct forctl {
  105.     char type;
  106.     union ctl_data_val {
  107.         struct {           /* eg. "for ($i=0; $i<100; $i++)" */
  108.             struct expression *e1; 
  109.             struct expression *e2;
  110.             struct expression *e3;
  111.         } c;
  112.         struct {           /* eg. "for ($i in $obj)" */
  113.             struct expression *i;
  114.             struct expression *obj;
  115.         } l;
  116.     } val;
  117. };
  118.  
  119. struct dataitem {
  120.     int start, end;
  121.     struct expression *exp;
  122. };
  123.  
  124. struct command {
  125.     char  type;
  126.  
  127.     union cmd_value {
  128.         struct cmd_if_struct {
  129.             struct expression   *cond;
  130.             int                  else_line; 
  131.             int                  end_line;
  132.         } cmd_if;
  133.  
  134.         struct cmd_function_struct {
  135.             int            name;
  136.             struct  param *par;
  137.             int            end_line;
  138.         } cmd_function;
  139.  
  140.         struct cmd_switch_struct {
  141.             struct expression     *cond;
  142.             struct caselist       *cl;
  143.             int                    end_line;
  144.         } cmd_switch;
  145.  
  146.         struct cmd_for_struct {
  147.             struct forctl ctl;
  148.             int end_line;
  149.         } cmd_for;
  150.  
  151.         struct cmd_exp_struct {           /* return, exp, embed, emit, exit */
  152.             struct expression *e;
  153.         } cmd_exp;
  154.  
  155.         struct cmd_data_struct {
  156.             struct dataitem *tab;
  157.             unsigned size, count;
  158.         } cmd_data;
  159.         
  160.         struct cmd_local_struct {
  161.             int name;
  162.         } cmd_local;
  163.         
  164.         struct cmd_use_struct {
  165.             int name;
  166.         } cmd_use;
  167.         
  168.         struct cmd_goto_struct {
  169.             int line;
  170.         } cmd_goto;
  171.     } cmd;
  172. };
  173.  
  174. struct sourcefile {
  175.     int        fname;
  176.     struct txttab *tt;
  177.     struct lintab *lt;
  178. };
  179.  
  180. struct sysfun {
  181.     int            name;
  182.     struct  param *par;
  183.     int          (*fun)( void );
  184. };
  185.  
  186. #endif
  187.